package thingtest.game;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyboardControl implements KeyListener{
	
	private GameModel gameModel;
	private Player player;

	public KeyboardControl(GameModel model){
		
		this.gameModel = model;
		player = this.gameModel.getPlayer();
		
	}

	@Override
	public void keyPressed(KeyEvent event) {
		
		if (event.getKeyCode() == KeyEvent.VK_UP) player.moveInDirection(new Vector(0,-1));
		if (event.getKeyCode() == KeyEvent.VK_LEFT) player.moveInDirection(new Vector(-1,0));
		if (event.getKeyCode() == KeyEvent.VK_RIGHT) player.moveInDirection(new Vector(1,0));
		if (event.getKeyCode() == KeyEvent.VK_DOWN) player.moveInDirection(new Vector(0,1));
		if (event.getKeyCode() == KeyEvent.VK_SPACE) player.shoot();
		
		
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		player.moveInDirection(new Vector(0,0));
		//this.gameModel.advanceFrame();
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
